Skip to content

20260227 Coverity changes#9842

Merged
douzzer merged 5 commits intowolfSSL:masterfrom
rlm2002:coverity
Mar 5, 2026
Merged

20260227 Coverity changes#9842
douzzer merged 5 commits intowolfSSL:masterfrom
rlm2002:coverity

Conversation

@rlm2002
Copy link
Copy Markdown
Contributor

@rlm2002 rlm2002 commented Feb 27, 2026

Description

Addresses CIDs

  • 187144 Logically dead code - add another variable to check original type (WOLF_PRIVATE_KEY_ID overwrites type if enabled)
  • 557579, 557574 Overflowed return value - adds temporary int variable to catch negative value before casting to word32
  • 557863 Dereference before null check - removes redundant NULL check
  • 307397 Operands don't affect result - checks n < 0 and returns MP_VAL if true. removes n > 0x7fffffff check.
  • 557877 OVERRUN - add hashAlgSz > RSA_PSS_ALGOID_TMPBUF_SZ before calling XMEMCPY()

Testing

./configure --enable-all && make check

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@rlm2002 rlm2002 assigned wolfSSL-Bot and unassigned rlm2002 Mar 3, 2026
@rlm2002 rlm2002 marked this pull request as ready for review March 3, 2026 18:39
@JacobBarthelmeh JacobBarthelmeh requested a review from Copilot March 3, 2026 23:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies a set of targeted Coverity-driven hardening fixes across wolfCrypt’s HPKE and ASN.1/PEM/CRL encoding/decoding paths to eliminate dead code, prevent unsafe casts, and add bounds checks.

Changes:

  • HPKE: tighten I2OSP() validation by rejecting negative inputs and removing a dead/ineffective upper-bound check.
  • ASN.1: add a temporary-buffer bounds check for RSA-PSS AlgoId encoding and simplify a redundant NULL check after prior argument validation.
  • PEM/CRL: preserve the original PEM “type” across internal remapping and prevent negative return values from being cast to word32 during CRL encoding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
wolfcrypt/src/hpke.c Adjusts I2OSP() validation to address Coverity findings (negative input handling, remove dead check).
wolfcrypt/src/asn.c Adds RSA-PSS temp-buffer bounds check, simplifies RSA public key decode index reset, preserves original PEM type, and fixes CRL size casting issues.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@douzzer douzzer added the Staged Staged for merge pending final test results and review label Mar 5, 2026
@douzzer douzzer merged commit b2913d2 into wolfSSL:master Mar 5, 2026
454 of 457 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Staged Staged for merge pending final test results and review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants